﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace YF_Music.Modules.APP_My.Controls
{
  /// <summary>
  /// AvatarImage.xaml 的交互逻辑
  /// </summary>
  public partial class AvatarImage : UserControl
  {
    public AvatarImage()
    {
      InitializeComponent();
    }
    public ImageSource ImageSource
    {
      get => (ImageSource)GetValue(ImageSourceProperty);
      set => SetValue(ImageSourceProperty, value);
    }
    public static readonly DependencyProperty ImageSourceProperty =
        DependencyProperty.Register(nameof(ImageSource), typeof(ImageSource), typeof(AvatarImage), new PropertyMetadata(null));




    public int Radius
    {
      get { return (int)GetValue(RadiusProperty); }
      set { SetValue(RadiusProperty, value); }
    }

    public static readonly DependencyProperty RadiusProperty =
        DependencyProperty.Register("Radius", typeof(int), typeof(AvatarImage), new PropertyMetadata(8));


    public ICommand ClickCommand
    {
      get => (ICommand)GetValue(ClickCommandProperty);
      set => SetValue(ClickCommandProperty, value);
    }

    public static readonly DependencyProperty ClickCommandProperty =
        DependencyProperty.Register("ClickCommand", typeof(ICommand), typeof(AvatarImage), new PropertyMetadata(null));

    private void Border_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    {
      if (ClickCommand?.CanExecute(null) == true)
      {
        ClickCommand.Execute(null);
      }
    }
  }
}
